package com.zareal.ymcc.feign;

import com.zareal.ymcc.domain.Login;
import com.zareal.ymcc.enums.GlobalErrorCode;
import com.zareal.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginFeignClientFallbackFactory implements FallbackFactory<LoginFeignClient> {
    @Override
    public LoginFeignClient create(Throwable e) {
        e.printStackTrace();
        log.error("login降级报错");
        return new LoginFeignClient() {
            @Override
            public JSONResult saveOrUpdate(Login login) {
                return JSONResult.success(GlobalErrorCode.ERROR);
            }
        };
    }
}
